package com.lanxin.oa.zu.controller;

import com.lanxin.bean.JcBasicdatavalue;
import com.lanxin.bean.MpCardtype;
import com.lanxin.bean.MpContact;
import com.lanxin.bean.ZzDepartment;
import com.lanxin.oa.zu.service.MingPianService;
import com.lanxin.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("mingpian")
public class MingPianController {
    @Autowired
    private MingPianService mpservice;
    @RequestMapping("select")
    public ModelAndView selectzcmp(Integer page, Integer pageSize, String name, String sex, String company, Integer typeid, String officePhone){
        PageBean list=mpservice.selectmp(page,pageSize,name,sex,company,typeid,officePhone);
        List<MpCardtype> type =mpservice.selectzu();
        ModelAndView mv=new ModelAndView();
        mv.addObject("list",list);
        mv.addObject("type",type);
        mv.setViewName("../view/zu/mingpianlist.jsp");
        return mv;
    }
    @RequestMapping("selectpl")
    public ModelAndView selectplmp(Integer page, Integer pageSize, String name, String sex, String company, Integer typeid, String officePhone){
        PageBean list=mpservice.selectmp(page,pageSize,name,sex,company,typeid,officePhone);
        List<MpCardtype> type =mpservice.selectzu();
        ModelAndView mv=new ModelAndView();
        mv.addObject("list",list);
        mv.addObject("type",type);
        mv.setViewName("../view/zu/mingpianpiliang.jsp");
        return mv;
    }
    @RequestMapping("toAddMp")
    public ModelAndView toAddMp(){
        ModelAndView mv=new ModelAndView();
        List<MpCardtype> type =mpservice.selectzu();
        mv.addObject("type",type);
        mv.setViewName("../view/zu/addmingpian.jsp");
        return mv;
    }
    @RequestMapping("insert")
    public ModelAndView insertMp(MpContact mpContact){
        mpservice.insertmp(mpContact);
        ModelAndView mv=new ModelAndView();
        mv.setViewName("redirect:select");
        return mv;
    }

    @RequestMapping("toUpdateMp")
    public ModelAndView toUpdateMp(Integer oid){
        ModelAndView mv=new ModelAndView();
        MpContact mp=mpservice.selectmpByid(oid);
        List<MpCardtype> type =mpservice.selectzu();
        mv.addObject("type",type);
        mv.addObject("mp",mp);
        mv.setViewName("../view/zu/updatemingpian.jsp");
        return mv;
    }
    @RequestMapping("update")
    public ModelAndView updateMp(MpContact mpContact){
        mpservice.updatemp(mpContact);
        ModelAndView mv=new ModelAndView();
        mv.setViewName("redirect:select");
        return mv;
    }

    @RequestMapping("xiangqing")
    public ModelAndView Mpxiangqing(Integer oid){
        ModelAndView mv=new ModelAndView();
        MpContact mp=mpservice.selectmpByid(oid);
        mv.addObject("mp",mp);
        mv.setViewName("../view/zu/mingpianxq.jsp");
        return mv;
    }

    @RequestMapping("yidong")
    public ModelAndView yidongMp(Integer typeid, String mids){
        mpservice.yidongmp(typeid,mids);
        ModelAndView mv=new ModelAndView();
        mv.setViewName("redirect:selectpl");
        return mv;
    }

}
